package com.atguigu.rabblitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitConnection {

        public static Connection getRabbitConnection() throws IOException, TimeoutException {
        //获取rabbitmq连接
        /*
        * 创建mq连接工厂
        * host地址
        * 端口号
        * 账号密码
        * 虚拟主机
        *
        * */

        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.87.129");
        factory.setPort(5672);
        factory.setUsername("admin");
        factory.setPassword("admin");
        factory.setVirtualHost("/gyf");
        factory.setConnectionTimeout(5000);
        return factory.newConnection();


    }
}
